package personal.wang.juc.completableFuture.pipeline;


import java.util.concurrent.Callable;
import java.util.function.*;

/**
 * @className: SomeFunctionalInterface
 * @Description:
 * @Author: wangyifei
 * @Date: 2025/3/11 10:23
 */
public class SomeFunctionalInterface {
    public static void main(String[] args) {
        Consumer<Integer> consumer = (x)->{
            System.out.println(x);
        };
        Consumer<Integer> consumer2 = System.out::println;
        consumer2.accept(1);
        LazyInterface l =  System.out::println;
        LazyInterface l1 = SomeFunctionalInterface::accept ;

        BiConsumer<Integer , Integer> biConsumer = (x , y) -> {
            System.out.println(x + y);
        };
        biConsumer.accept(1 , 2);
        Function<Integer,Integer> function = SomeFunctionalInterface::plus;
        System.out.println(function.apply(1));
        BiFunction<Integer , Integer , Integer> biFunction = SomeFunctionalInterface::accept;
        System.out.println(biFunction.apply(1, 2));
        Supplier<Integer> supplier = new Supplier<Integer>() {
            @Override
            public Integer get() {
                return 1;
            }
        };
        System.out.println(supplier.get());
        Supplier<Integer> supplier1 = () -> 1 ;
        System.out.println(supplier1.get());
        Callable<Integer> callable = ()-> 1;
        try {
            System.out.println(callable.call());
        } catch (Exception e) {
            e.printStackTrace();
        }
        Runnable r = ()->{
            System.out.println("Runnable");
        };
    }
    public static Integer plus(Integer integer) {
        return integer + 1 ;
    }

    public static Integer accept(Integer x, Integer y) {
        return x + y;
    }

    public static void accept(Integer x){
        System.out.println(x);
    }
    public interface LazyInterface{
        void handle(Integer x);
    }
}
